package edu.zcmu.seckill.controller;


import edu.zcmu.seckill.entity.Product;
import edu.zcmu.seckill.response.R;
import edu.zcmu.seckill.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author 唐诗
 * @since 2022-02-22
 */
@Slf4j
@RestController
@RequestMapping("/seckill/product")
public class ProductController {

    @Autowired
    ProductService service;

    @GetMapping("/getProduct/{page}")
    public R getProduct(@PathVariable Long page){
        log.info("查询第{}页产品的信息",page);
        Map<String,Object> map=service.queryAllProduct(page);
        return R.ok().data(map);
    }

    @GetMapping("/getProductDetail/{id}")
    public R getProductDetail(@PathVariable String id){
        log.info("查询产品id={}的信息",id);
        Map<String, Object> product = service.getProductById(id);
        return R.ok().data(product);
    }

}
